
#ifndef __KHAN__
#define __KHAN__

#include <stdio.h>
#include <linux/types.h>

#include <cstdlib>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <set>

#include <assert.h> /* for debug */

#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/bind.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/asio/basic_streambuf.hpp>


#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>

#ifdef Linux
#pragma warning (disable:981)
#pragma warning (disable:424)
#pragma warning (disable:593)
#pragma warning (disable:238)
#pragma warning (disable:181)
#pragma warning (disable:383)
#pragma warning (disable:869)
#pragma warning (disable:444)
#pragma warning (disable:68)
#pragma warning (disable:1418)
#pragma warning (disable:1419)
#pragma warning (disable:177)
#endif

namespace posix = boost::asio::posix;
using boost::asio::ip::tcp;


#define KHAN_DEBUG
#ifdef KHAN_DEBUG
#define PDBG(__fmt, __args ...) printf("[%s:%s:%d] " __fmt, __FILE__, __FUNCTION__, __LINE__, ## __args)
#else 
#define PDBG(__fmt, __args ...) 
#endif  /* end KHAN_DEBUG */
#define PINFO(__fmt, __args ...) printf(__fmt, ## __args)

typedef int             khan_rst_t;
typedef std::vector<std::string>    string_vector;
typedef boost::shared_ptr<std::string> string_ptr;

typedef boost::circular_buffer<char>    circular_buffer;
typedef circular_buffer::array_range    array_range;

typedef boost::shared_ptr<posix::stream_descriptor> stream_descriptor_ptr;

/* boost system typedef */
typedef boost::system::error_code       sys_error_code;


/* boost asio typedef */
typedef boost::asio::io_service         io_service;
//typedef boost::asio::error              io_error;
//typedef boost::asio::placeholders       io_placeholders;
//typedef typename boost::asio::buffer             io_buffer;


typedef boost::asio::ip::tcp::socket    tcp_socket;
typedef boost::asio::ip::tcp::acceptor  tcp_acceptor;
typedef boost::asio::ip::tcp::resolver  tcp_resolver;
typedef boost::asio::ip::tcp::endpoint  tcp_endpoint;


typedef boost::shared_ptr<io_service>   io_service_ptr;
typedef boost::shared_ptr<tcp_socket>   tcp_socket_ptr;
typedef boost::shared_ptr<tcp_acceptor> tcp_acceptor_ptr;


bool kstrtok(const std::string& str, const std::string& delim, string_vector& vec);


#endif  /* __KHAN__ */
